/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package old;

import gov.nasa.worldwind.geom.Position;
import visualization.Main.AppFrame;

/**
 *
 * @author Dark Mark
 */
public class LogicThread extends Thread
{
    double minDistance=5000, maxDistance=8000;
    double altitude=0;
    AppFrame appFrame;

    public LogicThread(AppFrame appFrame)
    {
        this.appFrame = appFrame;
    }

    @Override
    public void run()
    {
        while (true)
        {
            altitude = appFrame.getWwd().getView().getEyePosition().getAltitude();
            if (altitude <= maxDistance+minDistance)
            {
                appFrame.getWwd().getModel().getLayers().get(3).setOpacity((altitude-minDistance)/maxDistance);
                appFrame.getWwd().getModel().getLayers().get(4).setOpacity((altitude-minDistance)/maxDistance);
                appFrame.getWwd().getModel().getLayers().get(1).setEnabled(false);
            }
            else
            {
                appFrame.getWwd().getModel().getLayers().get(3).setOpacity(1.0);
                appFrame.getWwd().getModel().getLayers().get(4).setOpacity(1.0);
                appFrame.getWwd().getModel().getLayers().get(1).setEnabled(true);
            }

            try
            {
                Thread.sleep(1000 / 60);
            }
            catch (InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    }
}
